package org.kardigen.lg.main.client;

import org.kardigen.lg.main.client.main.MainView;
import org.kardigen.lg.main.client.main.MainViewPresenter;
import org.kardigen.lg.main.shared.service.WordService;
import org.kardigen.lg.main.shared.service.WordServiceAsync;
import org.kardigen.lg.service.client.requestfactory.TrainingRequestFactory;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class MainEntryPoint implements EntryPoint {
	/**
	 * The message displayed to the user when the server cannot be reached or
	 * returns an error.
	 */
	private static final String SERVER_ERROR = "An error occurred while "
	      + "attempting to contact the server. Please check your network " + "connection and try again.";

	/**
	 * Create a remote service proxy to talk to the server-side Greeting service.
	 */
	private final WordServiceAsync wordService = GWT.create(WordService.class);

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {

		RootPanel rootPanel = RootPanel.get("mainPanel");

		MainView view = new MainView();
		rootPanel.add(view.asWidget());

		TrainingRequestFactory requestFactory = (TrainingRequestFactory) GWT.create(TrainingRequestFactory.class);
		requestFactory.initialize(new SimpleEventBus());
		MainViewPresenter presenter = new MainViewPresenter(view, requestFactory);
		presenter.start();

	}

}
